//
//  WalletViewController.m
//  NiuBanJinGold
//
//  Created by Billy on 15/10/10.
//  Copyright © 2015年 zzjr. All rights reserved.
//

#import "WalletViewController.h"
#import "WalletCenterView.h"
#import "TicketExcahngeAndSigningController.h"
#import "IncomeViewController.h"
#import "IDCardAuthenticationViewController.h"
#import "TicketsViewController.h"
#import "AssetDetailsViewController.h"
#import "User.h"
#import "BankCardBindingViewController.h"
#import "DepositViewController.h"
#import "WebViewController.h"
#import "AgreementViewController.h"
#import "SDCycleScrollView.h"
#import "ADImage.h"
#import "AllH5ShownViewController.h"
#import "UserMessageListController.h"


@interface WalletViewController ()<SDCycleScrollViewDelegate>

//12 月15号小版本

@property (nonatomic, strong) SDCycleScrollView *view_adScrollView; //广告轮播图
@property (nonatomic, strong) UIView *view_rating; //年化收益展示
@property (nonatomic, strong) UIView *view_bottom_deposit;// 底部存入 加文案view
@property (nonatomic, strong) NSMutableArray *mutableArray_ADImages; //轮播图数据源
@property (nonatomic, strong) NSMutableDictionary *mutableDictionary_messages; //轮播图数据源

@property (nonatomic, strong) UIButton *button_saveMoney;// 立即存入按钮

@property (nonatomic, copy) NSString *str_signScore;//签到得了多少积分

@property (nonatomic, strong) NSArray *array_defaultBannerUrls;
@property (nonatomic, strong) NSArray *array_defaultBannerTitles;

@end

@implementation WalletViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self pageSettingsAndSubviewsCreation];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    [self getDataFromServer]; //包括得到消息列表和轮播图
}

#pragma mark - Data souce of current page

- (void) getDataFromServer {
    
    
    // 更新利率如果有变化的话
    
    [self updateUserRating];
    
    
    // 轮播图

    NSDictionary *dic_adParams = @{@"location":@"nqb_mb_home"};
    
    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    
    [[NetworkUtil sharedNetworkUtil] zzjr_getADImagesByParmeteres:dic_adParams transferResultUsingBlock:^(id parsedData, NSError *error) {

        [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
        
        if (!error) {
            
            self.mutableArray_ADImages = parsedData;
            
            if ([self.mutableArray_ADImages count] > 0) {
                
                [self updateADScrollView]; //重新定义党滚动图片
            }
        }else {
            
//            [UsefulUtil showAlertView:@"遇到网络问题，请稍候重试!"];
        }
    }];
    
    //消息中心
    
    dispatch_async(dispatch_get_main_queue(), ^{

        NSDictionary *dic_Params = @{@"userId":GETCURRENTUSERINOBYPRAMETERES(user_userId),@"token":GETCURRENTUSERINOBYPRAMETERES(user_userToken),@"offSet":@"1"};
        
        [[NetworkUtil sharedNetworkUtil] zzjr_getUserMessageListByParmeteres:dic_Params transferResultUsingBlock:^(id parsedData, NSError *error) {
            
            if (!error) {
                
               self.mutableDictionary_messages = parsedData;
                
                // 是不是要显示红点
                NSString *str_unreadNumber = [self.mutableDictionary_messages objectForKey:@"messageUnreadNumber"];
                
                if (![str_unreadNumber isEqualToString:@"0"]) {

                    [self setLeftBarButtonAfterDataLoaded];
                }else {

                    [self setLeftBarButton];
                }
            }else {
                
//                [UsefulUtil showAlertView:@"遇到网络问题，请稍候重试!"];
            }
        }];
    });
    
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSDictionary *dic_params = @{@"userId":GETCURRENTUSERINOBYPRAMETERES(user_userId),@"token":GETCURRENTUSERINOBYPRAMETERES(user_userToken)};
    
        [[NetworkUtil sharedNetworkUtil] zzjrGetUserAssetsByParmeteres:dic_params transferResultUsingBlock:^(id parsedData, NSError *error) {
            
            if (!error) {
                
                NSDictionary *dic_result = parsedData;
                
                if ([dic_result[@"status"] integerValue] == 0) { //正确得到数据
                
                    User *user = [[UserManager sharedUserManager] getCurrentUser];
                
                    user.user_isCardBinding = dic_result[@"result"][@"cardBinding"];
                    user.user_userScores = dic_result[@"result"][@"scores"];
                    user.user_annualRate = dic_result[@"result"][@"annualRate"];
                    user.user_ticketRate = dic_result[@"result"][@"ticketRate"];
                    [[UserManager sharedUserManager] saveCurrentUser:user];
                }
                
            }else {
                
//                [UsefulUtil showAlertView:error.description];
            }
        }];

    });
    
}

- (void) updateADScrollView {
    
    CGRect frame = self.view_adScrollView.frame;
    NSArray *array_images = [self.mutableArray_ADImages valueForKey:@"adImage_imageURLString"];
    
    [self.view_adScrollView removeFromSuperview]; //移除再添加
    
    self.view_adScrollView = [SDCycleScrollView cycleScrollViewWithFrame:frame imageURLStringsGroup:array_images];
    
    [self.view_adScrollView  setAutoScrollTimeInterval:2.0];
    [self.view_adScrollView setPageControlAliment:SDCycleScrollViewPageContolAlimentRight];
    [self.view_adScrollView setDelegate:self];
        [self.view_adScrollView setTag:89];

    [self.view addSubview:self.view_adScrollView];
}

#pragma mark - Scrollview delegate

- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
    
    NSString *str_url = nil; //跳转的URL
    NSString *str_title = nil; //对应的title
    
    if (cycleScrollView.tag == 88) {
        
        str_url = self.array_defaultBannerUrls[index];
        str_title = self.array_defaultBannerTitles[index];

    }else {
        
        str_url = [self.mutableArray_ADImages[index] valueForKey:@"adImage_refURL"];
        str_title = [self.mutableArray_ADImages[index] valueForKey:@"adImage_title"];
    }
    
    if (str_url) {
        
        AllH5ShownViewController *h5VC = [[AllH5ShownViewController alloc] init];
        
        [h5VC setStr_url:str_url];
        [h5VC setStr_title:str_title];
        
        [h5VC setHidesBottomBarWhenPushed:YES];
        
        [self.navigationController pushViewController:h5VC animated:YES];
    }
}
- (void) updateUserRating {
    
    UILabel *label_rateShow = [self.view_rating viewWithTag:50];
    
    //基本年利率
    NSString *str_annualRate = GETCURRENTUSERINOBYPRAMETERES(user_annualRate);
    
    // 用户加息利率
    NSString *str_addRate = GETCURRENTUSERINOBYPRAMETERES(user_ticketRate);
    
    NSString *str_content = [NSString stringWithFormat:@"%@%%+%@%%",str_annualRate,str_addRate];
    
    if (str_content) {
        
        NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:str_content];
        
        [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:iPhone4? 60:70.0] range:NSMakeRange(0, str_annualRate.length)];//8
        [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:iPhone4? 30:35.0] range:NSMakeRange(str_annualRate.length , 2)]; //%+
        
        [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:iPhone4? 60:70.0] range:NSMakeRange(str_annualRate.length+2 , str_addRate.length)]; //1
        
        [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:iPhone4? 30:35.0] range:NSMakeRange(str_content.length - 1, 1)]; //%
        
        [label_rateShow setAttributedText:attrStr];
    }
}

#pragma mark - Button click events handling

- (void) buttonEventsHandling:(UIButton *) button {
    
    switch (button.tag) {
            
        case 20: //消息中心
            
        {
            [self messageCenter];
        }
            break;
            
        case 21: //签到
        {
            [self dailySign];
        }
            break;
        case 22: //存钱
        {
            [self depositMoney];
        }
            break;
        case 30: //理财协议
        {
            AgreementViewController *agreemantVC = [[AgreementViewController alloc]init];
            agreemantVC.hidesBottomBarWhenPushed = YES;
            
            [self.navigationController pushViewController:agreemantVC animated:YES];
        }
            break;
        case 31: //什么是牛钱包
        {
            WebViewController *weVC = [[WebViewController alloc]init];
            [weVC setIndex:4];
            [weVC setHidesBottomBarWhenPushed:YES];
            
            [self.navigationController pushViewController:weVC animated:YES];
        }
            break;
        default:
            break;
    }
}

- (void) dailySign {
    
    NSDictionary *dic_params = @{@"token" :[UserManager sharedUserManager].user.user_userToken , @"userId" : [UserManager sharedUserManager].user.user_userId};
    
    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    
    [[NetworkUtil sharedNetworkUtil] zzjrScore_usersignByParmeteres:dic_params transferResultUsingBlock:^(id parsedData, NSError *error) {
        
        [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
        
        if (!error) {
            
            NSDictionary *dic_result = (NSDictionary *) parsedData ;
            
            if ([dic_result[@"status"] integerValue] == 0) {
                
                self.str_signScore = dic_result[@"result"][@"todaySignScore"];
                
                //保存最新积分
    
                User *tmp = [[UserManager sharedUserManager] getCurrentUser];
                tmp.user_userScores = dic_result[@"result"][@"score"];
                [[UserManager sharedUserManager] saveCurrentUser:tmp];
                
                UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:[NSString stringWithFormat:@"获得积分:%@",self.str_signScore] message: nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
                
                [alertView show];
            }else if ([dic_result[@"status"] integerValue] == 3) {
                
                self.str_signScore = dic_result[@"result"][@"todaySignScore"];
                
                //保存最新积分
                
                User *tmp = [[UserManager sharedUserManager] getCurrentUser];
                tmp.user_userScores = dic_result[@"result"][@"score"];
                [[UserManager sharedUserManager] saveCurrentUser:tmp];
                
                [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
                
                UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:dic_result[@"msg"] message: nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
                [alertView show];
            }
            
        }else {
            
            [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
            [UsefulUtil showAlertView:@"遇到网络问题，请稍候重试!"];
        }
    }];
}

- (void) messageCenter { //消息中心

//    NSArray *array_messages = self.mutableDictionary_messages[@"messageArray"];
    
//    if ([array_messages count] > 0) {
    
        UserMessageListController *messageVC = [[UserMessageListController alloc] init];
        [messageVC setHidesBottomBarWhenPushed:YES];
        
        [self.navigationController pushViewController:messageVC animated:YES];
//    }
}

- (void) depositMoney {
    
    if (![[UserManager sharedUserManager] isAuthentication]) { //没有实名认证
        
        // 跳到存入钱的logic
        
        IDCardAuthenticationViewController *authenticationVC = [[IDCardAuthenticationViewController alloc] init];
        authenticationVC.Type = 0;
        [authenticationVC setHidesBottomBarWhenPushed:YES];
        
        [self.navigationController pushViewController:authenticationVC animated:YES];
    }else  { //通过了实名认证
        
        if ([[UserManager sharedUserManager] isCardBinding]) { //已经绑定过卡,跳不同的存入界面
            
            DepositViewController *deposeVC = [[DepositViewController alloc] init];
            [deposeVC setHidesBottomBarWhenPushed:YES];
            
            [self.navigationController pushViewController:deposeVC animated:YES];
        }else {
            
            //跳到绑定存入page
            BankCardBindingViewController *bankVC = [[BankCardBindingViewController alloc] init];
            [bankVC setHidesBottomBarWhenPushed:YES];
            
            [self.navigationController pushViewController:bankVC animated:YES];
        }
    }
}

#pragma mark - Alert view delegate (handle sign)

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    
    if (buttonIndex == 0) {
        
        TicketExcahngeAndSigningController *signingVC = [[TicketExcahngeAndSigningController alloc] init];
        [signingVC setType:@"sign"];
        [signingVC setHidesBottomBarWhenPushed:YES];
        [signingVC setStr_signScore:self.str_signScore];
        
        [self.navigationController pushViewController:signingVC animated:YES];
    }
}


#pragma mark - SubviewsCreationAndPageSettings

- (void) pageSettingsAndSubviewsCreation {
    
    [self.navigationItem setTitle:@"牛钱包"];
    
    // 左右righbarbutton
    
    [self setRightAndLeftBarButton];
    
    // 添加子界面
    
    [self.view addSubview:self.view_adScrollView];
    [self.view addSubview:self.view_rating];
    [self.view addSubview:self.view_bottom_deposit];
}

- (void) setRightAndLeftBarButton {
    
    //1. left
    
    [self setLeftBarButton];
    
    //2. right
    
    UIButton *button_right = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, MULTIPLYWIDTH(100.0/2), 44.0)];
    [button_right setTitleColor:APPCOLOR(@"#5f5f61") forState:UIControlStateNormal];
    [button_right setTitle:@"签到" forState:UIControlStateNormal];
    [button_right.titleLabel setFont:[UIFont systemFontOfSize:15.0]];
    [button_right.titleLabel setAdjustsFontSizeToFitWidth:YES];

    UIBarButtonItem *item_right = [[UIBarButtonItem alloc] initWithCustomView:button_right];
    UIBarButtonItem *negativeSpace = [[UIBarButtonItem alloc]
                                       initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
                                       target:nil action:nil];
    [negativeSpace setWidth:MULTIPLYWIDTH(-15.0)];
    
    [self.navigationItem setRightBarButtonItems:@[negativeSpace,item_right]];
    
    //3. add target
    
    [button_right setTag:21];

    [button_right addTarget:self action:@selector(buttonEventsHandling:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)setLeftBarButton {
    
    UIButton *button_left = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, MULTIPLYWIDTH(137.0/2), 32.0)];
    [button_left setTitleColor:APPCOLOR(@"#5f5f61") forState:UIControlStateNormal];
    [button_left setTitle:@"消息中心" forState:UIControlStateNormal];
    [button_left.titleLabel setFont:[UIFont systemFontOfSize:15.0]];
    
    [button_left.titleLabel setAdjustsFontSizeToFitWidth:YES];
    
    UIBarButtonItem *negativeSpace_left = [[UIBarButtonItem alloc]
                                           initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
                                           target:nil action:nil];
    [negativeSpace_left setWidth:MULTIPLYWIDTH(-15)];
    
    UIBarButtonItem *item_left = [[UIBarButtonItem alloc] initWithCustomView:button_left];
    
    [self.navigationItem setLeftBarButtonItems:@[negativeSpace_left,item_left]];
    
    [button_left setTag:20];
    
    [button_left addTarget:self action:@selector(buttonEventsHandling:) forControlEvents:UIControlEventTouchUpInside];
}

- (void) setLeftBarButtonAfterDataLoaded {
    
    UIButton *button_left = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, MULTIPLYWIDTH(137.0/2), 32.0)];
    [button_left setTitleColor:APPCOLOR(@"#5f5f61") forState:UIControlStateNormal];

    [button_left setImage:[UIImage imageNamed:@"messageUnRead"] forState:UIControlStateNormal];
    
    [button_left.titleLabel setFont:[UIFont systemFontOfSize:15.0]];
    
    [button_left.titleLabel setAdjustsFontSizeToFitWidth:YES];
    
    UIBarButtonItem *negativeSpace_left = [[UIBarButtonItem alloc]
                                           initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
                                           target:nil action:nil];
    [negativeSpace_left setWidth:MULTIPLYWIDTH(0)];
    
    UIBarButtonItem *item_left = [[UIBarButtonItem alloc] initWithCustomView:button_left];
    
    [self.navigationItem setLeftBarButtonItems:@[negativeSpace_left,item_left]];
    
    [button_left setTag:20];
    
    [button_left addTarget:self action:@selector(buttonEventsHandling:) forControlEvents:UIControlEventTouchUpInside];

}
#pragma mark - Delay loading (setter methods)

- (NSArray *)array_defaultBannerTitles {
    
    if (!_array_defaultBannerTitles) {
        
        _array_defaultBannerTitles = @[@"多重保障 保驾护航",@"多重保障 保驾护航",@"多重保障 保驾护航",@"投资有礼"];
    }

    return _array_defaultBannerTitles;
}

- (NSArray *)array_defaultBannerUrls {
    
    if (!_array_defaultBannerUrls) {
        
        _array_defaultBannerUrls = @[@"http://style.niubangold.com/app/banner_1.html",@"http://style.niubangold.com/app/banner_2.html",@"http://style.niubangold.com/app/banner_3.html",@"http://style.niubangold.com/app/banner_4.html"];
    }
    
    return _array_defaultBannerUrls;
}

//广告展示view : 没有得到server数据的时候用默认图

- (SDCycleScrollView *)view_adScrollView {
    
    if (!_view_adScrollView) {
        
        UIImage *image_banner1 = [UIImage imageNamed:@"banner1"];
        UIImage *image_banner2 = [UIImage imageNamed:@"banner2"];
        UIImage *image_banner3 = [UIImage imageNamed:@"banner3"];
        UIImage *image_banner4 = [UIImage imageNamed:@"banner4"];
        
        _view_adScrollView  = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, MULTIPLYHEIGHT(240.0/2)) imagesGroup:@[image_banner1,image_banner2,image_banner3,image_banner4]];
        [_view_adScrollView setDelegate:self];
        [_view_adScrollView setTag:88];
        [_view_adScrollView setPageControlAliment:SDCycleScrollViewPageContolAlimentRight];
    }
    
    return _view_adScrollView;
}

- (UIView *)view_rating {
    
    if (!_view_rating) {
        
        _view_rating = [UsefulUtil viewCreationWithFrame:CGRectMake(0, CGRectGetMaxY(self.view_adScrollView.frame), SCREEN_WIDTH, MULTIPLYHEIGHT(630.0/2)) backgroundColor:APPCOLOR(@"#f8f8f8") backGroundImage:nil];
        
        //中间的利率图
        
        UIImageView *imageView_rate = [UsefulUtil imageViewCreationWithFrame:CGRectMake(MULTIPLYWIDTH(140.0/2), MULTIPLYHEIGHT(52.0/2), MULTIPLYWIDTH(492.0/2), MULTIPLYHEIGHT(464.0/2)) image:[UIImage imageNamed:@"big-circle"]];
        
        [_view_rating addSubview:imageView_rate];
        
        // 年化收益提示
        
        UILabel *label_ratePrompt = [UsefulUtil labelCreationWithFrame:CGRectMake(imageView_rate.frame.origin.x +MULTIPLYWIDTH(-10.0/2), MULTIPLYHEIGHT(122.0/2), MULTIPLYWIDTH(492.0/2), MULTIPLYHEIGHT(30.0/2)) textColor:APPCOLOR(@"#434343") fontName:[UIFont systemFontOfSize:15.0] text:@"年化收益"];
        
        [label_ratePrompt setTextAlignment:NSTextAlignmentCenter];
        [_view_rating addSubview:label_ratePrompt];
        
        // 年化收益显示
        
        UILabel *label_rateShow= [UsefulUtil labelCreationWithFrame:CGRectMake(imageView_rate.frame.origin.x, CGRectGetMaxY(label_ratePrompt.frame) +MULTIPLYHEIGHT(40.0/2), MULTIPLYWIDTH(492.0/2), MULTIPLYHEIGHT(122.0/2)) textColor:APPCOLOR(@"#434343") fontName:[UIFont systemFontOfSize:15.0] text:nil];
        
        [label_rateShow setTextAlignment:NSTextAlignmentCenter];
        [label_rateShow setTextColor:REDCOLOR];
        [label_rateShow setTag:50];
        
        [_view_rating addSubview:label_rateShow];
        
        //基本年利率
        NSString *str_annualRate = GETCURRENTUSERINOBYPRAMETERES(user_annualRate);
        
        // 用户加息利率
        NSString *str_addRate = GETCURRENTUSERINOBYPRAMETERES(user_ticketRate);
        
        NSString *str_content = [NSString stringWithFormat:@"%@%%+%@%%",str_annualRate,str_addRate];
        
        if (str_content) {
            
            NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:str_content];
            
            [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:iPhone4? 60:70.0] range:NSMakeRange(0, str_annualRate.length)];//8
            [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:iPhone4? 30:35.0] range:NSMakeRange(str_annualRate.length , 2)]; //%+
            
            [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:iPhone4? 60:70.0] range:NSMakeRange(str_annualRate.length+2 , str_addRate.length)]; //1
            
            [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:iPhone4? 30:35.0] range:NSMakeRange(str_content.length - 1, 1)]; //%
            
            [label_rateShow setAttributedText:attrStr];
        }
        
        // 起存图片
        
        UIImageView *imageView_placeHolder = [UsefulUtil imageViewCreationWithFrame:CGRectMake(MULTIPLYWIDTH(93.0/2), CGRectGetMaxY(imageView_rate.frame) + MULTIPLYHEIGHT(57.0/2), MULTIPLYWIDTH(178.0/2), MULTIPLYHEIGHT(32.0/2)) image:[UIImage imageNamed:@"placeHolder"]];
        
        [_view_rating addSubview:imageView_placeHolder];
        
        // 随存随取
        
        UIImageView *imageView_saveFree = [UsefulUtil imageViewCreationWithFrame:CGRectMake(MULTIPLYWIDTH(40.0/2) + CGRectGetMaxX(imageView_placeHolder.frame), imageView_placeHolder.frame.origin.y, MULTIPLYWIDTH(155.0/2), MULTIPLYHEIGHT(32.0/2)) image:[UIImage imageNamed:@"saveFree"]];
        
        [_view_rating addSubview:imageView_saveFree];
        
        // 本息保障
        UIImageView *imageView_safeRate = [UsefulUtil imageViewCreationWithFrame:CGRectMake(MULTIPLYWIDTH(40.0/2) + CGRectGetMaxX(imageView_saveFree.frame),  imageView_placeHolder.frame.origin.y, MULTIPLYWIDTH(156.0/2), MULTIPLYHEIGHT(32.0/2)) image:[UIImage imageNamed:@"safeRate"]];
        
        [_view_rating addSubview:imageView_safeRate];
        
    }
    
    return _view_rating;
}

- (UIView *)view_bottom_deposit {
    
    if (!_view_bottom_deposit) {
        
        _view_bottom_deposit = [UsefulUtil viewCreationWithFrame:CGRectMake(0, CGRectGetMaxY(self.view_rating.frame), SCREEN_WIDTH, MULTIPLYHEIGHT(242.0/2)) backgroundColor:APPCOLOR(@"#ffffff") backGroundImage:nil];
        
        self.button_saveMoney = [UsefulUtil buttonCreationWithFrame:CGRectMake(MULTIPLYWIDTH(60.0/2), MULTIPLYHEIGHT(35.0/2), SCREEN_WIDTH - MULTIPLYWIDTH(120.0/2), MULTIPLYHEIGHT(90.0/2)) textColor:REDCOLOR fontName:[UIFont systemFontOfSize:17.0] text:@"立即存入"];
        [_view_bottom_deposit addSubview:self.button_saveMoney];
        
        [self.button_saveMoney setTag:22];
        [_view_bottom_deposit setBackgroundColor:[UIColor whiteColor]];
        
        [self.button_saveMoney addTarget:self action:@selector(buttonEventsHandling:) forControlEvents:UIControlEventTouchUpInside];
        
        [self.button_saveMoney.layer setBorderColor:REDCOLOR.CGColor];
        [self.button_saveMoney.layer setBorderWidth:1.0];
        [self.button_saveMoney.layer setCornerRadius:20.0];
        
        
        // 理财协议
        // 牛钱包投资协议
        
        UIButton *button_invest = [UsefulUtil buttonCreationWithFrame:CGRectMake(0, MULTIPLYHEIGHT(26.0/2) + CGRectGetMaxY(self.button_saveMoney.frame), SCREEN_WIDTH/2, MULTIPLYHEIGHT(90.0/2)) textColor:[UsefulUtil colorWithHexString:@"#336699"] fontName:[UIFont boldSystemFontOfSize:15.0] text:@""];
        
        [_view_bottom_deposit addSubview: button_invest];
        
        UIImageView *image_invest = [[UIImageView alloc] initWithFrame:CGRectMake(MULTIPLYWIDTH(60.0/2), 0, MULTIPLYWIDTH(194.0/2), MULTIPLYHEIGHT(23.0/2))];
        
        [image_invest setImage:[UIImage imageNamed:@"wallet01"]];
        
        [button_invest addSubview:image_invest];
        
        // 什么是牛钱包
        
        UIButton *button_nameExplain = [UsefulUtil buttonCreationWithFrame:CGRectMake(SCREEN_WIDTH/2, button_invest.frame.origin.y, SCREEN_WIDTH/2, MULTIPLYHEIGHT(90.0/2)) textColor:[UsefulUtil colorWithHexString:@"#336699"] fontName:[UIFont boldSystemFontOfSize:15.0] text:@""];
        
        [_view_bottom_deposit addSubview: button_nameExplain];
        
        UIImageView *image_nameExplain = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2 - MULTIPLYWIDTH(242.0/2), 0, MULTIPLYWIDTH(182.0/2), MULTIPLYHEIGHT(23.0/2))];
        
        [image_nameExplain setImage:[UIImage imageNamed:@"wallet02"]];
        
        [button_nameExplain addSubview:image_nameExplain];
        
        //添加事件
        
        [button_invest addTarget:self action:@selector(buttonEventsHandling:) forControlEvents:UIControlEventTouchUpInside];
        [button_nameExplain addTarget:self action:@selector(buttonEventsHandling:) forControlEvents:UIControlEventTouchUpInside];
        
        [button_invest setTag:30];
        [button_nameExplain setTag:31];
    }
    
    return _view_bottom_deposit;
}

// 所有广告图片对象

- (NSMutableArray *)mutableArray_ADImages {
    
    if (!_mutableArray_ADImages) {
        
        _mutableArray_ADImages = [NSMutableArray array];
    }
    
    return _mutableArray_ADImages;
}

#pragma mark - Memory warning

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

@end
